Namespace Actions
    Public Class ActionResult

        Public Enum ResultType
            rtTextFile
            rtExcelFile
        End Enum

        Public Class Presenter
            Public Sub ShowAsTextFile(ByVal FileName As String)
                Dim FileContents As String = vbNullString
                Try
                    FileContents = IO.File.ReadAllText(FileName)
                Catch ex As Exception
                    Exit Sub
                End Try

                Dim frm As New frmProcessResultViewerTextFile(FileName, FileContents)
                frm.Show()
            End Sub
        End Class

        Public ReadOnly Name As String = "No name"
        Public ReadOnly Type As ResultType
        Public ReadOnly FileName As String

        Private _Presenter As New Presenter

        Public Sub Show()
            Show(Type)
        End Sub

        Public Sub Show(ByVal ShowAsResultType As ResultType)
            Select Case ShowAsResultType
                Case ResultType.rtTextFile
                    _Presenter.ShowAsTextFile(FileName)
                Case Else
                    MsgBox("Nie umiem :(")
            End Select
        End Sub

        Public Sub New(ByVal FileName As String)
            Me.FileName = FileName
            Me.Name = IO.Path.GetFileName(FileName)
        End Sub

        Public Shared Function RecognizeFileType(ByVal FileName As String) As ResultType
            Dim FileExt As String = IO.Path.GetExtension(FileName)
            If FileExt = "xls" Then
                RecognizeFileType = ResultType.rtExcelFile
            Else
                RecognizeFileType = ResultType.rtTextFile
            End If
        End Function


    End Class
End Namespace